package il.ac.biu.cs.grossmm.api.simple;

import il.ac.biu.cs.grossmm.api.flow.NodeEventInspector;
import il.ac.biu.cs.grossmm.api.flow.Status;
import il.ac.biu.cs.grossmm.api.keys.Key;

import java.util.Set;

/**
 * Represents an internal active data subscription information
 * which backs up one or more SIP subscriptions (for
 * the same resurce, but possibly with different SIP-specific
 * parameters such as a timeout).
 *
 */
public interface InternalSubscription {
	/**
	 * Gets key for this internal subscriptio
	 * 
	 * @return key for this internal subscriptio
	 */
	Key getKey();

	/**
	 * Gets current status of this internal subscriotionn
	 * 
	 * @return current status of the internal subscriotion
	 */
	Status getStatus();

	/**
	 * Gets set of all sip subscriptions backed by this internal subscription
	 * 
	 * @return set of all sip subscriptions backed by this internal subscription
	 */
	Set<SipSubscription> getSipSubscriptrions();

	/**
	 * Add a new sip subscription to the set of all sip subscriptions backed by
	 * this internal subscription
	 * 
	 * @param subscription
	 *            a new sip subscription to be added to the set of all sip
	 *            subscriptions backed by this internal subscription
	 */
	void addSipSubscription(SipSubscription subscription);

	/**
	 * Remove a sip subscription from the set of all sip subscriptions backed by
	 * this internal subscription
	 * 
	 * @param subscription
	 *            a sip subscription to be removed from the set of all sip
	 *            subscriptions backed by this internal subscription
	 */
	void removeSipSubscripttion(SipSubscription subscription);

	/**
	 * Gets the body for NOTIFY request which reflects the current resource
	 * state. The body is generated using the speified mime type, which must be
	 * one of mime types supported by corresponding event package.
	 * 
	 * @param mimeType
	 *            the mime type for NOTIFY request body
	 * @return NOTIFY request body in specified mime type, which reflects the
	 *         current resource state
	 */
	Payload getPayload(SipSubscription sipSub);

	/**
	 * Gets the body for NOTIFY request which reflects the resource state
	 * modifiation. The body is generated using the speified mime type, which
	 * must be one of mime types supported by corresponding event package.
	 * 
	 * @param inspector
	 *            the inspector to inspect the resource state modification
	 * 
	 * @param mimeType
	 *            the mime type for NOTIFY request body
	 * 
	 * @return NOTIFY request body in specified mime type, which reflects the
	 *         resource state modification
	 */
	Payload getPayload(NodeEventInspector inspector, SipSubscription sipSub);
}
